package com.cxh.rmsq.net.self

import android.content.Context
import com.pcl.mvvm.network.api.DeBugApiService
import okhttp3.MultipartBody
import java.util.*

/**
 *   @auther : Aleyn
 *   time   : 2019/11/01
 */
class NetWork {
    var context: Context? = null

        private val mService by lazy { RetrofitSelfClient.getInstance().create(DeBugApiService::class.java) }


    suspend fun getSendSmsCode(mapOf: HashMap<String, Any>) = mService.getSendSmsCode(mapOf)
//    suspend fun getSmsLogin(mapOf: HashMap<String, Any>) = mService.getSmsLogin(mapOf)
//
//    suspend fun getLogin(mapOf: HashMap<String, Any>) = mService.getLogin(mapOf)

    suspend fun getLogout(mapOf: HashMap<String, Any>) = mService.getLogout(mapOf)

    suspend fun setAuthentication(mapOf: HashMap<String, Any>) = mService.setAuthentication(mapOf)

    suspend fun getAuthentication(userId: Int) = mService.getAuthentication(userId)

    suspend fun getUserUpdate(mapOf: HashMap<String, Any>) = mService.getUserUpdate(mapOf)

    suspend fun getProvinceList() = mService.getProvinceList()

    suspend fun getCityList(code: String) = mService.getCityList(code)

    suspend fun getAreaList(code: String) = mService.getAreaList(code)

    suspend fun getUserInfo(userId: String) = mService.getUserInfo(userId)

    suspend fun getFileUpdate(img: MultipartBody.Part) = mService.getFileUpdate(img)


    suspend fun changePwd(mapOf: HashMap<String, Any>) = mService.changePwd(mapOf)

    suspend fun changePhone(mapOf: HashMap<String, Any>) = mService.changePhone(mapOf)

    companion object {
        @Volatile
        private var netWork: NetWork? = null

        fun getInstance() = netWork ?: synchronized(this) {
            netWork ?: NetWork().also { netWork = it }
        }
    }


}